#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include<stdlib.h>

typedef struct TreeNode
{
    char val;
    struct TreeNode* left;
    struct TreeNode* right;
}tn;

tn* maketree(char* arr, int* count)
{
    if (arr[*count] == '#' || arr[*count] == '\0')
        return NULL;
    tn* newtn = (tn*)malloc(sizeof(tn));
    newtn->val = arr[(*count)++];
    newtn->left = maketree(arr, count);
    (*count)++;
    newtn->right = maketree(arr, count);
    return newtn;
}

void zhong(tn* root)
{
    if (root == NULL)
        return;
    zhong(root->left);
    printf("%c ", root->val);
    zhong(root->right);
}

int main()
{
    char arr[101];
    scanf("%s", arr);
    int count = 0;
    tn* tree = maketree(arr, &count);
    zhong(tree);
    return 0;
}